package com.noble.meether.chat.ui.agora.act.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.noble.library.base.bean.BaseData;

import org.json.JSONObject;

/**
 * Created by Su on 2017/7/20.
 */
public class Props extends BaseData implements Parcelable {
    private int id;         // 道具id
    private String icon;    // 道具图片
    private String bundle;  // 道具下载地址
    private int price;      // 使用道具价格
    private String name;    // 道具名称

    private boolean isFirst; // 区分tag

    @Override
    public void parseJson(String jsonStr) {
        JSONObject object = getJsonObject(jsonStr);
        this.id = object.optInt("id");
        this.icon = object.optString("icon");
        this.bundle = object.optString("bundle");
        this.price = object.optInt("price");
        this.name = object.optString("name");

        this.isFirst = false;
    }

    public boolean isFirst() {
        return isFirst;
    }

    public void setFirst(boolean first) {
        isFirst = first;
    }

    public int getId() {
        return id;
    }

    public String getIcon() {
        return icon;
    }

    public String getBundle() {
        return bundle;
    }

    public int getPrice() {
        return price;
    }

    public String getName() {
        return name;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeString(this.icon);
        dest.writeString(this.bundle);
        dest.writeInt(this.price);
        dest.writeString(this.name);
        dest.writeByte(this.isFirst ? (byte) 1 : (byte) 0);
    }

    public Props() {
    }

    protected Props(Parcel in) {
        this.id = in.readInt();
        this.icon = in.readString();
        this.bundle = in.readString();
        this.price = in.readInt();
        this.name = in.readString();
        this.isFirst = in.readByte() != 0;
    }

    public static final Creator<Props> CREATOR = new Creator<Props>() {
        @Override
        public Props createFromParcel(Parcel source) {
            return new Props(source);
        }

        @Override
        public Props[] newArray(int size) {
            return new Props[size];
        }
    };

    @Override
    public String toString() {
        return "Props{" +
                "id=" + id +
                ", icon='" + icon + '\'' +
                ", bundle='" + bundle + '\'' +
                ", price=" + price +
                ", name='" + name + '\'' +
                ", isFirst=" + isFirst +
                '}';
    }
}
